Skip to content

stream: copy SAB-backed chunks in iter consumers#64382

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-arrayBuffer-consumers-sab
Open

stream: copy SAB-backed chunks in iter consumers#64382
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-arrayBuffer-consumers-sab

Conversation

@trivikr

@trivikr trivikr commented Jul 9, 2026

Copy link
Copy Markdown
Member

Fixes: #64381

This updates the stream/iter byte consumers to avoid preserving
SharedArrayBuffer backing stores when collecting a single full-buffer chunk.

bytes() and bytesSync() now copy SAB-backed chunks into a new
Uint8Array, and arrayBuffer() / arrayBufferSync() defensively copy
SAB-backed data into a normal ArrayBuffer.

The existing SharedArrayBuffer stream/iter test coverage has been tightened to
assert that SAB-backed input produces non-shared output for these consumers.


Assisted-by: openai:gpt-5.5

Ensure bytes() copies single chunks backed by SharedArrayBuffer so
arrayBuffer() and arrayBufferSync() return ArrayBuffer instances as
specified.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Jul 9, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 9, 2026
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (0032189) to head (70fa4ce).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/streams/iter/consumers.js 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64382      +/-   ##
==========================================
- Coverage   90.23%   90.23%   -0.01%     
==========================================
  Files         741      741              
  Lines      241194   241197       +3     
  Branches    45432    45427       -5     
==========================================
  Hits       217640   217640              
+ Misses      15129    15124       -5     
- Partials     8425     8433       +8     
Files with missing lines Coverage Δ
lib/internal/streams/iter/utils.js 98.21% <100.00%> (+0.02%) ⬆️
lib/internal/streams/iter/consumers.js 96.63% <50.00%> (-0.52%) ⬇️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stream/iter: arrayBuffer consumers return SharedArrayBuffer for SAB-backed chunks

3 participants